<!--Generate by Kevin's CodeBuilder -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
		<meta charset="UTF-8">
		<title>bui-ssm快速开发框架</title>
		<head th:include="source::header"></head>
		<script type="application/javascript" th:src="@{/static/lib/emotionConfig.js}"></script>
    	<script type="application/javascript" th:src="@{/static/lib/editConfig.js}"></script>
    	<script type="application/javascript" th:src="@{/static/lib/edit-0.0.1.js}"></script>
</head>
<body>
		<input type="hidden" id="id" name="id" th:value="*{id}"/>
		<div style="height: 100%; width:100%;position:relative;">
			<div style="height:35px;width:100%;position:absolute;top:0;z-index:2;">
				输入描述：<input type="text" id="desp" name="desp" style="width:300px;margin-top:3px;"/>
			</div>
			<div class="k_box_size" style="height:100%;width:100%;position:absolute;top:0;z-index:1;border-top:36px solid #fff;">
					<div id="editor">
					
					</div>
			</div>
		</div>
		
</div>
<script type="application/javascript" th:inline="javascript">
		var kedit,entityJson,idValue;
		$(function () {
			idValue = $("#id").val();
			if(idValue === ""){
				entityJson = {};
			}else{
				entityJson = [(${entityJson})];
				$("#desp").val(entityJson.desp);
			}			
			var editor = $("#editor");
            kedit = new $B.Edit(editor, {
            	/* mobile:true, */
            	onChange:function(content){
            		console.log(content);
            		/* $B.window({
                        width: 200,
                        height: 32,
                        iconCls: 'fa-volume-control-phone',
                        title: '保存提示', //标题
                        shadow: true, //是否需要阴影
                        timeout: 1.5, //5秒钟后自动关闭，0表示不自动关闭
                        mask: false, //是否需要遮罩层
                        radius: false, //是否圆角
                        header: false, //是否显示头部
                        position: 'top', // top :顶部中间，bottom：右下角
                        content: '<p style="text-align:center;line-height:30px;">内容已经保存！</p>',               
                        draggable: false, //是否可以拖动               
                        closeable: false, //是否关闭                   
                        maxminable: false, //可变化小大
                        collapseable: false
                    }); 
                    $B.request({
                    	url : $B.getHttpHost(ctxPath) + "dict/editor",
                    	data:{  id:   idValue,
                    			ext:  encodeURIComponent(content),
                    			desp: $("#desp").val(),
                    			_not_url_decode_: 1 //不需要服务端的url decode 
                    	},
                    	ok:function(){                    		              		
                    	},
                    	fail:function(){                    		
                    	},
                    	final:function(res){                    		
                    	}
                    }); */
            	},
                width: '100%',
                height: '100%',
                uploadImg: {
                    label: '请选择图片',
                    url:  $B.getHttpHost(ctxPath) +'main/upload',
                    onSuccess: function (res) {
                        console.log("上传成功！" + JSON.stringify(res));
                    },
                    onError: function (res) {
                        console.log("onError " + JSON.stringify(res));
                    },
                    setParams: function () {
                        return {
                            "ext_params": "ext"
                        };
                    }
                },
                uploadFile: {
                    label: '请选择文件',
                    url: $B.getHttpHost(ctxPath) +'main/upload',
                    onSuccess: function (res) {
                        console.log("上传成功！" + JSON.stringify(res));
                    },
                    onError: function (res) {
                        console.log("onError " + JSON.stringify(res));
                    },
                    setParams: function () {
                        return {
                            "ext_params": "ext"
                        };
                    }
                },                
                /***将base64转为图片，返回图片链接***/
                onInsertMap: function (base64Img) {
                    return base64Img;
                },
                onSave:function(html,ecodeHtml){
                    console.log(html);
                    this.attr("disabled",true);
                    var btn = this;
                    var msg = $B.message("正在保存......");
                    $B.request({
                    	url : $B.getHttpHost(ctxPath) + "dict/editor",
                    	data:{  id:idValue,
                    			ext:ecodeHtml,
                    			desp:$("#desp").val(),
                    			_not_url_decode_:1 //不需要服务端的url decode 
                    	},
                    	ok:function(){
                    		console.log("保存成功 >>>>");
                    		$B.success("保存成功！",1.2);
                    		setTimeout(function(){
                    			parent.curdObj.reload();
                    		},1000);                    		
                    	},
                    	fail:function(){
                    		/* $B.error("保存失败！"); */
                    	},
                    	final:function(res){
                    		msg.close();
                    		btn.removeAttr("disabled");
                    		console.log("final >>>>>");
                    	}
                    });
                }
            });
            console.log("idValue == "+idValue);
            if(idValue !== "" && entityJson.extFiled && entityJson.extFiled !== ""){
            	console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            	//console.log(entityJson.extFiled);
            	kedit.setHtmlString(entityJson.extFiled);
            }
		});
		
</script>
</body>
</html>
